package com.blog.service;

import java.util.List;
import com.blog.dao.BLogQueryDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blog.domain.Album;
import com.blog.domain.Blog;
import com.blog.domain.Category;
import com.blog.domain.Comment;
import com.blog.domain.Photo;
import com.blog.domain.User;


@Service("BlogService")
public class BlogService {
    
	@Autowired
	private BLogQueryDao dao;

	public User queryUser(String mailId, String password) {
		return dao.getUser(mailId, password);
	}

	public User queryUserByName(String name){
		return dao.getUserByName(name);
	}
	public Blog queryBlog(int id) {
		return dao.getBlog(id);
	}

	public List<Blog> queryBlogs(int s,int e) {
		return dao.getBlogs(s, e);
	}
	
	public Blog queryTopBlog() {
		return dao.getTopBlog();
	}
	public List<Blog> queryBlogsByCateId(int cid) {
		return dao.getBlogsByCateId(cid);
	}
	
	public List<Category> queryCategorys() {
		return dao.getCategorys();
	}

	public List<Comment> queryComments(int blogId) {
		return dao.getComments(blogId);
	}

	public List<Comment> queryFirst10Comments() {
		return dao.getFirst10Comments();
	}
	public List<Album> queryAlbumDetails() {
		return dao.getAlbumDetails();
	}
	
	public List<Album> queryAlbums() {
		return dao.getAlbums();
	}
	
	public int saveCategory(Category cate){
		return dao.insertCategory(cate);
	}
	
	public int saveBlog(Blog blog){
		return dao.insertBlog(blog);
	}
	
	public int savePhoto(Photo photo){
		return dao.insertPhoto(photo);
	}

	public int saveAlbum(Album album){
		return dao.insertAlbum(album);
	}
	
	public int saveComment(Comment com){
		return dao.insertComment(com);
	}

	public int updateUserPhoto(String uid ,String path){
		return dao.updateUserPhoto(uid, path);		
	}
}
